//
//  ViewController.m
//  UI_07_UIViewControllerLifeCycle
//
//  Created by li cheng on 16/7/22.
//  Copyright © 2016年 li cheng. All rights reserved.
//

#import "ViewController.h"
#import "FirstViewController.h"

@interface ViewController ()

@end

@implementation ViewController
#pragma mark - life clycy
// loadView 和 viewDidLoad 只走一次
- (void)loadView{
    [super loadView];
    NSLog(@"%@----------%s", [self class], __FUNCTION__);
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor redColor];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"回去" style:UIBarButtonItemStylePlain target:self action:@selector(buttonClicked:)];
}


- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    NSLog(@"%@----------%s", [self class], __FUNCTION__);
}



- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    NSLog(@"%@----------%s", [self class], __FUNCTION__);
}
// 视图将要消失时,就会被调用 只有一点消失
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    NSLog(@"%@----------%s", [self class], __FUNCTION__);
}
// 视图已经完全消失
- (void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
    NSLog(@"%@----------%s", [self class], __FUNCTION__);

}

#pragma mark - buttonClicked
- (void)buttonClicked:(UIButton *)button{
    FirstViewController *vc = [[FirstViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
